// #include <set>
#ifndef CLOUD_HPP
#define CLOUD_HPP


#include <WiFi.h>
#include <WiFiClient.h>
#include <HTTPClient.h>
#include "mbedtls/base64.h"


String _region="China";
String _email="18559220052";
String _username="18559220052";
String _auth_token;
String _password="25845630";
// String ssid="218-3";
// String Password="218520520";


void connectToWifi(char* ssid, char*  Password){
    WiFi.mode(WIFI_STA);
    WiFi.begin(ssid, Password);
    delay(1000);
    wl_status_t status = WiFi.status();
    
    bool reboot = false;
    const char *statusText = "";
    while (status != WL_CONNECTED)
    {

        switch (status)
        {
        case WL_IDLE_STATUS:
            statusText = " 连接中...";
            break;

        case WL_NO_SSID_AVAIL:
            statusText = " SSID错误";
            reboot = true;
            break;

            // case WL_CONNECTION_LOST:
            //     break;

        case WL_CONNECT_FAILED:
        case WL_DISCONNECTED:
            statusText = " 请检查WIFI凭据";
            reboot = true;
            break;

        default:
            break;
        }

        if (statusText != "")
        {
            Serial.println(statusText);
            delay(32);
        }

        if (reboot)
        {
            delay(3000);
            ESP.restart();
        }
        status = WiFi.status();
    }
}


#endif // CLOUD_HPP